<?php
	$config = Config::read('config');
?>
<table class="table-login">
	<tr>
		<td><span><?php echo ucfirst(_("user")); ?>:</span></td>
		<td class="td-logout"><?php echo Auth::get('account'); ?></td>
	</tr>
	<tr>
		<td rowspan="3" style="text-align: center;">
			<script type="text/javascript">
			window.addEvent('domready', function()
			{
				
				
				
				
				var options = {
		/*
			upload restrictions
		*/
		
		base: 'fuck/upload.php',
		
		//you cannot upload more than 3 files
		limit: 0,
		
		// Máxima cantidad de archivos que se pueden arrastrar
		draglimit: 1,
		
		//each file size must be less than 2.5Mb
		//filesize: 2621440,
		filesize: 5500621440,
		//total files size must not exceed 3.5Mb
		//maxsize: 3670016,
		maxsize: 5500621440,
		
		//use iframe
		iframe: false,
		
		//upload container id
		container: 'upload',
		
		//filter uploaded file type
		//filetype: 'html,rar,zip',
		
		//upload field name
		name: 'alias',
		//limit: 2, /* limit to two downloads */
		multiple: false, //enable multiple selection in file dialog
		progressbar: {

			width: 140, //fix the progressbar width
			color: '#000', 
			fillColor: '#fff',
			text: 'Pending...',
			onChange: function (value, progressbar) {
			
				//console.log(arguments)
				progressbar.setText('completed: ' + (100 * value).format() + '%')
			}
		},
	/*
		
		onCreate: function (transfer) {
		
			//do something
		},
	*/
		onAbort: function (object) {
		
			//alert('Upload aborted:\n' + object.message)
		},
		onCancel: function (obj) {
		
			//upload size
			/*
			$('infos').set('html', uploadManager.getSize('upload').toFileSize());
			if(obj.message) alert('Upload cancelled:\n' + obj.message)
			*/
			
		},
		onSuccess: function (infos) {
			
			//$('div.upload-container').destroy();
			//alert("Fuck");
			//$('upload').getElement('div.upload-container').destroy();
			//alert($('upload').getElement('div.upload-container').get('html'));
			//uploadManager.upload(options);
			//upload size
			//$('infos').set('html', uploadManager.getSize('upload').toFileSize());
			//console.log(infos.file);
			//download link
			//new Element('span', {style: 'display: none;', html: '<a href="upload.php?' + infos.path + '&dl=1&filename=' + infos.file + '">download</a> -&nbsp;'}).inject($(infos.transfer).getElement('a'), 'before')
		},
		onAllComplete: function (container)
		{
			$('upload').getLast('div.upload-container').setStyle('display', 'none');
			
			if (!uploadManager.getDragAndDrop())
				uploadManager.upload(options);
			else
			{
				var _div = $('upload').getLast('div.upload-container').getPrevious('div.upload-container').dispose();
				_div.inject($('upload'));
			}
				
			uploadManager.setDragAndDrop(false);
				
			//var _div = $('upload').getLast('div.upload-container').getPrevious('div.upload-container');
			//alert("fuck");
			
			//if (_div == null)
			//	_div = $('upload').getLast('div.upload-container');
			
			//_div.setStyle('display', 'none');
			
			//uploadManager.upload(options);
			
			//alert("fuck");
			/*var message = 'all transfers completed for "' + container + '"';
			
			if(window.console && console.log) console.log(message);
			else alert(message);*/
		}
	};

uploadManager.attachDragEvents('upload', options);
uploadManager.upload(options);
/*document.getElement('a').addEvent('click', function(e) {

	e.stop();
	uploadManager.upload(options)
});*/

var tipsupload = new Tips($$('.tipsupload'), 
				{
					showDelay: 400,
					hideDelay: 400,
					text: "data-text",
					fixed: true,
					onShow: function(tip, el)
					{
						tip.addClass('tipfile');
						tip.setStyle('display', 'block');
					},
					onHide: function(tip, el)
					{
						tip.removeClass('tipfile');
						tip.setStyle('display', 'none');
					}
				});
});
			</script>
			<div id="fileimage">
				<?php echo Form::open("", "post", array("id" => "form-avatar", "name" => "form-avatar")); ?>
					<div id="upload"></div>
				<?php echo Form::close(); ?>
				<div id="avatar" class="divfileimage" style="display: none;">
					<?php echo Html::img("upload/" . Auth::get('image'), "class: imgavatar"); ?>
				</div>
			</div>
		</td>
		<td class="td-logout"><?php echo  date("d/m/y"); ?><br /><?php echo Html::link("", 'text: ' . $config['application']['domain'], 'style: font-size: 8px; text-decoration: none;'); ?></td>
	</tr>
	<tr>
		<td class="td-logout" style="height: 10px;"><?php echo Html::link('profile', 'text: ' . ucfirst(_("edit profile"))); ?></td>
	</tr>
	<tr>
		<td class="td-logout" style="height: 10px;"><?php echo Html::link('login/logout', 'text: ' . ucfirst(_("sign out"))); ?></td>
	</tr>
</table>